<template>
	<el-form ref="form" label-width="80px" @submit.prevent="onSubmit" >
			<el-form-item label="起始时间">
				<el-col :span="11">
					<el-date-picker format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="form.startDate"></el-date-picker>
				</el-col>
			</el-form-item>
			<el-form-item label="终止时间">
				<el-col :span="11">
					<el-date-picker format="yyyy-MM-dd" type="date" placeholder="选择日期" v-model="form.endDate" ></el-date-picker>
				</el-col>
			</el-form-item>
			<el-form-item label="部门组别">
				<el-select v-model="form.department" placeholder="请选择部门" clearable>
					<el-option v-for="item in departmentList" :key="item.department_key" :label="item.department_name" :value="item.department_key"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="季节" >
				<el-select v-model="form.season" placeholder="请选择" clearable>
					<el-option v-for="item in seasonList" :key="item.season_id" :label="item.season_name" :value="item.season_id"></el-option>
				</el-select>
			</el-form-item>			
		</el-form>
</template>
<script type="text/javascript">
	import { query, apiparas, execute } from '../../api/api';
	import { Cookie } from '../../js/common';
	export default{
		data(){
			return{
				form:{
					startDate:'',
					endDate:'',
					department:'',
					season:'',
				},
				departmentList:[],
				seasonList:[],
			}
		},
		mounted(){
			let date = new Date();
			let y = date.getFullYear();
			let m = date.getMonth()+1 > 9 ? date.getMonth()+1 : '0'+(date.getMonth()+1);
			let d = date.getDate() > 9 ? date.getDate() : '0' + date.getDate();
//			this.form.startDate = y +'-'+m+'-'+d;
			this.form.endDate = y +'-'+m+'-'+d;
			//组件渲染后从后台请求列表数据
			this.getDepartment();
			this.getSeason();
		},
		methods:{
			getDepartment:function(){
	        	let jsonparas = [];
					//增加查询条件
				apiparas.pushPara(jsonparas, 'department_name', '');
					//查询汇总
				let _paras = apiparas.getParas('default','basic|get_department', jsonparas);
				query(_paras).then(response => {
					let json_data = response.result;
					this.departmentList = json_data;
				});
	        },
	        getSeason:function(){
	        	let jsonparas = [];
					//增加查询条件
					apiparas.pushPara(jsonparas, 'season_name', '');
					//查询汇总
					let _paras = apiparas.getParas('default','basic|get_season', jsonparas);
					query(_paras).then(response => {
						let json_data = response.result;
						this.seasonList = json_data;
					});
	        }
		}
		

	}
</script>
<style type="text/css">
	.el-form-item{
		display:inline-block;
		float: left;
		margin-left:10px;
	}
</style>
<style scoped>
	.el-form-item{
	    display: inline-block;
	    float: left;
	    width: 23%;
	    margin-left: 10px;
	}
	.el-col-11{
		width:100%;
	}
	.el-input{
		width:100%;
	}
	.el-select{
		width:100%;
	}
</style>